package course.dmsSpringBoot.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author zouran
 * createDate：2023/12/18  23:54
 */
public class CheckString {
    private static final String EMAIL_REGEX =
            "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";


    public static boolean isEmailValid(String email) {
        Pattern pattern = Pattern.compile(EMAIL_REGEX);
        Matcher matcher = pattern.matcher(email);
        return matcher.matches();
    }
    private static final String NON_CHINESE_REGEX = "^[^\\u4e00-\\u9fa5]+$";

    public static boolean isNonChineseString(String input) {
        Pattern pattern = Pattern.compile(NON_CHINESE_REGEX);
        return pattern.matcher(input).matches();
    }
}
